<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
    //   // 班长数据转JSON字符串
    //   var banzhang = {
    //     name: "杰哥",
    //     age: 18,
    //     tallRichUgly: true,
    //     belief: null,
    //     bros: [
    //       {
    //         name: "霖哥",
    //         nickname: "冬瓜",
    //       },
    //       {
    //         name: "荣姐",
    //         nickname: "大西瓜",
    //       },
    //     ],
    //   };

    //   //   将JS数据转化为JSON字符串
    //   var jsonStr = JSON.stringify(banzhang);
    //   console.log("将JS数据字符串化为JSON",jsonStr);

      // JSON字符串转班长数据
      var jsonStr = `
        {
            "name":"杰哥",
            "age":18,
            "tallRichUgly":true,
            "belief":null,
            "bros":[
                {
                "name":"霖哥",
                "nickname":"冬瓜"
                },
                {
                "name":"荣姐",
                "nickname":"大西瓜"
                }
            ]
        }
      `
    //   console.log(jsonStr);

      var jsData = JSON.parse(jsonStr)
      console.log("将JSON字符串解析为JS数据",jsData);
    </script>
  </body>
</html>
